package com.yangfei.mystudy1020.animation.AnimActivity;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ImageView;

import com.yangfei.mystudy1020.R;
import com.yangfei.mystudy1020.animation.view.SpringChainView;

import butterknife.BindView;
import butterknife.ButterKnife;

abstract class BaseAnimationActivity extends Activity {
    public static long DEFAULT_ANIMATION_DURATION = 2500L;

    @BindView(R.id.rocket)
    ImageView rocket;
    @BindView(R.id.doge)
    ImageView doge;
    @BindView(R.id.container)
    FrameLayout container;

    float screenHeight = 0.f;

    @BindView(R.id.sp_chain)
    SpringChainView spChain;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_anim_base);
        ButterKnife.bind(this);

        container.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onStartAnimation();
            }
        });
    }

    @Override
    protected void onResume() {
        super.onResume();

        WindowManager wm = (WindowManager) this.getSystemService(Context.WINDOW_SERVICE);
        DisplayMetrics dm = new DisplayMetrics();
        assert wm != null;
        wm.getDefaultDisplay().getMetrics(dm);
        screenHeight = dm.heightPixels;
    }

    protected abstract void onStartAnimation();

}
